package jaxb.metagrammar;

import java.util.UUID;

import javax.xml.bind.annotation.adapters.XmlAdapter;

import metagrammar.Operator;
import application.Application;

public class OperatorToUUIDStringAdapter extends XmlAdapter<String, Operator> {
    
    @Override
    public Operator unmarshal(String v) throws Exception
    {
        OperatorContext context = Application.injector.getInstance(OperatorContext.class);
        return context.getOperator(UUID.fromString(v));
    }
    
    @Override
    public String marshal(Operator v) throws Exception
    {
        return v.getId().toString();
    }
    
}
